import request from '@/utils/request'
const isLocal = process.env.VUE_APP_API_TYPE === 'local'

export function getList(api, params) {
  const url = isLocal ? '/product_carousel/getList' : `${api}carousels`
  return request({
    url: url,
    method: 'get',
    params: params,
  })
}

export function doCreate(api, data) {
  const url = isLocal ? '/product_carousel/doEdit' : `${api}carousels`
  return request({
    url: url,
    method: 'post',
    data: data,
  })
}

export function doEdit(api, data) {
  const url = isLocal
    ? '/product_carousel/doEdit'
    : `${api}carousels/${data.id}`
  return request({
    url: url,
    method: isLocal ? 'post' : 'put',
    data: data,
  })
}

export function doDelete(api, id) {
  const url = isLocal ? '/product_carousel/doDelete' : `${api}carousels/${id}`
  return request({
    url: url,
    method: 'delete',
  })
}

export function doDeletes(api, data) {
  const url = isLocal
    ? '/product_carousel/doDelete'
    : `${api}carousels?batch=true`
  return request({
    url: url,
    method: isLocal ? 'delete' : 'post',
    data: {
      method: 'delete',
      data,
    },
  })
}
